import {MaybeRef, Ref} from 'vue'
type pagination = {
    currentPage: number,
    pageSize: number,
    total:number
}
export default ()=>{
    function calculatePageNumbers(pagination: Ref<pagination>){
        const newCurrentPage = Math.ceil((pagination.value.total - 1) / pagination.value.pageSize)
        pagination.value.currentPage = pagination.value.currentPage > newCurrentPage ? newCurrentPage : pagination.value.currentPage
        pagination.value.currentPage = pagination.value.currentPage < 1 ? 1 : pagination.value.currentPage
    }
    return {calculatePageNumbers}
}
